<?php
/**
 * Created by dutuwang.net
 * User: adophper <hello@adophper.com>
 * Date: 2018/4/14
 * Time: 15:45
 */
use yii\helpers\Html;
?>
<?=Html::jsFile('/static/frontend/js/swipe.js')?>
<div class="same-exhibition">
    <div class="detailMin_box_min_right_title flex f_between f_relative">
        <i class="iconfont btn_red">&#xe67d;</i>
        <span>同期展会</span>
        <!--<em>更多<i></i></em>-->
    </div>
    <div class="detailMin_box_min_right_min">
        <div class="swipe same-box" id="same-exhibition">
            <div class="swipe-wrap">
                <?php
                if (!empty($data)) {
                    foreach ($data as $val) {
                ?>
                <div class="detailMin_box_min_right_banner">
                    <a href="<?=Yii::$app->urlManager->createUrl(['zhanhui/detail', 'id' => $val['id']])?>">
                        <img src="<?=$val['litpic']?>_305x190.jpg" />
                        <span><?=$val['title']?></span>
                    </a>
                </div>
                <?php
                    }
                }
                ?>
            </div>
            <div class="same-nav same-prev flex">
                <span class="same_prev"><i class="glyphicon glyphicon-menu-left"></i></span>
            </div>
            <div class="same-nav same-next flex">
                <span class="same_next"><i class="glyphicon glyphicon-menu-right"></i></span>
            </div>
        </div>
        <div class="same_nav" id="same_nav">
            <?php
            if (!empty($data)) {
                foreach ($data as $key =>$val) {
            ?>
            <span class="<?=$key==0?'on':''?>"></span>
            <?php
                }
            }
            ?>
        </div>
    </div>
</div>
<script>
    /*推荐城市展馆*/
    var same = Swipe(document.getElementById('same-exhibition'), {
        auto: 3000,
        continuous: true,
        callback: function(pos) {
            var i = bullets.length;
            while (i--) {
                bullets[i].className = '';
            }
            bullets[pos].className = 'on';
        }
    });
    var bullets = document.getElementById('same_nav').getElementsByTagName('span');
    $(function(){
        $(".same-prev").click(function(e){
            e.preventDefault();
            same.prev();
        });
        $(".same-next").click(function(e){
            e.preventDefault();
            same.next();
        });
    });
</script>